<template>
	<view class="container">
		<Header>反馈记录</Header>
		<view class="feedback">
			<view class="title">
				{{data.title}}
			</view>
			<view class="content">
				内容：{{data.content}}
			</view>
			<view class="date">
				{{data._createtime}}
			</view>
		</view>
		<view class="replay" v-if="data.reply_content">
			<view >
				答复：
			</view>
			<view class="content">
				{{data.reply_content}}
			</view>
			<view class="date">
				{{data.reply_time}}
			</view>
		</view>
	</view>
</template>

<script>
	import Header from '../../components/header.vue'
	import request from '../../common/request.js'
	export default {
		components: {
			Header
		},
		data() {
			return {
				id: '',
				data:{}
			}
		},
		onLoad(option) {
			this.id  = option.id
		},
		mounted(){
			this.getDetailData()
		},
		methods: {
			timestampToTime(timestamp) {
				  // 时间戳为10位需*1000，时间戳为13位不需乘1000
				  var date = new Date(timestamp * 1000);
				  var Y = date.getFullYear() + "-";
				  var M =
					(date.getMonth() + 1 < 10
					  ? "0" + (date.getMonth() + 1)
					  : date.getMonth() + 1) + "-";
				  var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
				  var h = date.getHours() + ":";
				  var m = date.getMinutes() + ":";
				  var s = date.getSeconds();
				  return Y + M + D ;
			},
			getDetailData(){
				request({
					url:'/feedback/detail',
					data:{
						opinions_id: this.id
					},
					method: 'POST'
				}).then(res => {
					if(res.code == 1){
						this.data = res.data
						this.data._createtime = this.timestampToTime(this.data.createtime)
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		background-color: #f9f9f9;
		min-height: calc(100vh - 45px);
		line-height: 26px;
	}
	.feedback{
		margin: 15px;
		border-radius: 12px;
		padding: 20px;
		background-color: rgba(234, 92, 85, 0.04);
		.title{
			color: #ea5c55;
		}
	}
	.replay{
		margin: 15px;
		border-radius: 12px;
		padding: 20px;
		background-color: rgba(38, 104, 190, 0.04);
	}
	.date{
		font-size: 12px;
		color: #808080;
	}
</style>